import 'package:flutter/material.dart';
import 'package:getx_scaffold/common/index.dart';
import 'package:oramemo/common/styles/colors.dart';
import 'package:oramemo/pages/transcription/transcription_recode/transcription_recode_logic.dart';
import 'package:oramemo/common/langs/text_key.dart';

import '../widgets/water_circle.dart';

class RecordView extends StatelessWidget {
  const RecordView({
    super.key,
  });

  @override
  Widget build(BuildContext context) {
    return GetBuilder<TranscriptionRecodeLogic>(builder: (logic) {
      return Stack(
        alignment: Alignment.center,
        children: [
          if (logic.isRecording)
            const SizedBox(
                width: 200,
                height: 200,
                child: WaterCircleLoading(
                  color: Colors.black,
                )),
          GestureDetector(
            onLongPressStart: (_) => logic.startRecording(),
            onLongPressEnd: (_) => logic.stopRecording(),
            onLongPressCancel: () => logic.stopRecording(),
            onTap: () => Toast.show(TextKey.recordHoldToStart.tr),
            child: Container(
              width: 120,
              height: 120,
              decoration: BoxDecoration(
                  color: Colors.black, borderRadius: BorderRadius.circular(60)),
              child: const Icon(
                AntdIcon.audio_fill,
                color: Colors.white,
                size: 50,
              ),
            ),
          ),
          Padding(
            padding: const EdgeInsets.only(top: 180.0),
            child: Text(
              logic.isRecording ? TextKey.recordReleaseToStop.tr : TextKey.recordHoldToStart.tr,
              style: const TextStyle(color: Colours.dark_text_gray, fontSize: 16),
            ),
          )
        ],
      );
    });
  }
}
